import 'package:flutter/material.dart';
import 'package:mpcore/mpkit/mpkit.dart';

import 'home_page.dart';
import 'mine_center_page.dart';

class MainPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MPMainTabView(
      tabs: [
        MPMainTabItem(
          activeTabWidget: Container(
            width: 44,
            height: 44,
            child: renderIcon(
              icon: MaterialIcons.home,
              title: '首页',
              actived: true,
            ),
          ),
          inactiveTabWidget: Container(
            width: 44,
            height: 44,
            child: renderIcon(
              icon: MaterialIcons.home,
              title: '首页',
              actived: false,
            ),
          ),
          builder: (context) => HomePage(),
        ),
        MPMainTabItem(
          activeTabWidget: Container(
            width: 44,
            height: 44,
            child: renderIcon(
              icon: MaterialIcons.light,
              title: '我的',
              actived: true,
            ),
          ),
          inactiveTabWidget: Container(
            width: 44,
            height: 44,
            child: renderIcon(
              icon: MaterialIcons.light,
              title: '我的',
              actived: false,
            ),
          ),
          builder: (context) => MineCenterPage(),
        )
      ],
      keepAlive: true,
    );
  }

  Widget renderIcon({
    required String icon,
    required String title,
    required bool actived,
  }) {
    return Column(
      children: [
        MPIcon(icon, color: actived ? Colors.blue : Colors.grey),
        Text(
          title,
          style: TextStyle(
            fontSize: 12,
            color: actived ? Colors.blue : Colors.grey,
          ),
        ),
      ],
    );
  }
}